/**
 * Studentmanager.java
 * 
 * This class is used globally for creating and managing professors.
 *
 * @author Felix Schuller
 */
package Runde2;

import java.util.ArrayList;

public class ProfessorManager {
	private static ArrayList<Professor> profList = new ArrayList<Professor>();
	
	/**
	 * Creates a new professor and adds it to the professors-list.
	 * 
	 * @params see Person
	 * @return created professor's profNr, used to "get" the Professor-object from ProfessorManager
	 */
	public static int createProf(String fName, String lName, String password) throws InvalidPersonException{
		try {
			Professor temp = new Professor(fName, lName, password);
			profList.add(temp);
			return profList.indexOf(temp);
		} catch (InvalidPersonException e) {
			throw new InvalidPersonException(e.getMessage());
		}

	}
	
	/**
	 * Returns Professor with given profNr from professors-list.
	 * 
	 * @param profNr - profNr
	 * @return Professor with given profNr
	 */
	public static Professor getProf(int profNr) {
		return profList.get(profNr);
	}
	
	/**
	 * Returns a readable form of professors-list
	 * 
	 * @return readable form of professors-list
	 */
	public static String getProfessorList() {
		String output = "";
		for (int i = 0; i < profList.size();i++) {
			output += "#" + i + ": " + profList.get(i) + "\n";
		}
		return output;
		
	}
	
}
